package com.andy.mvp.poetry.module;

import com.andy.app_core.net.databus.RxBus;
import com.andy.app_core.net.rx.RxRestClient;
import com.andy.mvp.poetry.bean.Proetry;

import java.util.ArrayList;
import java.util.HashMap;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * @version V1.0
 * @描述:
 * @Company:
 * @auth: Created by AN .
 * @time: 2020/3/27 18:56
 * @des
 */
public class ProetryModuleImpl implements IProetryModule {
     ArrayList<Proetry> data = new ArrayList<Proetry>();
    @Override
    public void loadProetry(int page) {
        HashMap<String,Object> params=new HashMap<>();
        params.put("page","peakchao");
        params.put("passwd","123456");
        RxRestClient.create().url("developerLogin").parms(params).build().post()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(String s) {
                        System.out.println("-----------------------"+s);
                        System.out.println("-----------------------"+"假装接口返回数据,组装返回");
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        data.add(new Proetry("太宗皇帝","帝京篇十首 一","秦川雄帝宅，函谷壮皇居。|绮殿千寻起，离宫百雉余。|连甍遥接汉，飞观迥凌虚。|云日隐层阙，风烟出绮疏。"));
                        RxBus.getInstance().sendData(data);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }
}
